<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>  
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<link rel="stylesheet" href="/resources/common/font.css">
<script language="JavaScript" src="/resources/js/common.js"></script>
<script>
function imageView(strImage)
{
	this.document.images["big"].src = strImage;
}

</script>
<title>Insert title here</title>

</head>
<body>
<br>
<jsp:include page="../main_header.jsp" flush="true"/>
<br>
<form name="form1" method="post" action="productEdit" enctype="multipart/form-data">
<center>

<br>
<table width="800" border="1" cellspacing="0" cellpadding="3" bordercolordark="white" bordercolorlight="black">
<c:forEach items="${ProductList}" var="product" >
	<tr> 
		<td width="700"  bgcolor="#F2F2F2">
			<input type="hidden" name="no" value="${product.NO}">
		</td>
	</tr>
	<tr>
		<td width="100" bgcolor="#CCCCCC" align="center">분류</td>
			<td width="700" bgcolor="#F2F2F2">
				<select name="category">
				  <option value="Outwear">Outwear</option>
				  <option value="Shirt">Shirt</option>
				  <option value="Sweater">Sweater</option>
				  <option value="Pants">Pants</option>
				  <option value="Jeans">Jeans</option>
				  <option value="Shoes">Shoes</option>
				</select>
			</td>
	</tr>
	<tr> 
		<td width="100" bgcolor="#CCCCCC" align="center">상품명</td>
		<td width="700"  bgcolor="#F2F2F2">
			<input type="text" name="NAME" value="${product.NAME}" size="60" maxlength="60">
		</td>
	</tr>

	<tr> 
		<td width="100" bgcolor="#CCCCCC" align="center">판매가</td>
		<td width="700"  bgcolor="#F2F2F2">
			<input type="text" name="PRICE" value="${product.PRICE}" size="12" maxlength="12"> 원
		</td>
	</tr>
	<tr> 
		<td width="100" bgcolor="#CCCCCC" align="center">옵션</td>
    <td width="700" bgcolor="#F2F2F2">
			<select name="opt1">
				<option value="0" selected>옵션선택</option>
				<c:forEach items="${detailList}" var="option">
					<option value="${option.no}">${option.name}</option>
				</c:forEach>
			</select> &nbsp; &nbsp; 

			<select name="opt2">
				<option value="0" selected>옵션선택</option>
				<c:forEach items="${detailList}" var="option">
					<option value="${option.no}">${option.name}</option>
				</c:forEach>
			</select> &nbsp; &nbsp; 
		</td>
	</tr>
	<tr> 
		<td width="100" bgcolor="#CCCCCC" align="center">제품설명</td>
		<td width="700"  bgcolor="#F2F2F2">
			<textarea name="description " rows="4" cols="70">${product.description }</textarea>
		</td>
	</tr>
	<tr> 
		<td width="100" bgcolor="#CCCCCC" align="center">상품상태</td>
    <td width="700"  bgcolor="#F2F2F2">
			<input type="radio" name="STATUS" value="1" checked> 판매중
			<input type="radio" name="STATUS" value="2"> 판매중지
			<input type="radio" name="STATUS" value="3"> 품절
		</td>
	</tr>
	<tr> 
		<td width="100" bgcolor="#CCCCCC" align="center">아이콘</td>
		<td width="700"  bgcolor="#F2F2F2">
		<c:choose>
			<c:when test="${Product.STATUS==1}"> <td width="50"  align="center">판매중</td>	 </c:when>
			<c:when test="${Product.STATUS==2}"> <td width="50"  align="center">판매중지</td>	 </c:when>
			<c:when test="${Product.STATUS==3}"> <td width="50"  align="center">품절</td>	 </c:when>
		</c:choose>
		<c:choose>
			<c:when test="${product.ICON_NEW!=null}"><input type="checkbox" name="ICON_NEW" value="1" checked> New &nbsp;&nbsp</c:when>
			<c:when test="${product.ICON_NEW==null}"><input type="checkbox" name="ICON_NEW" value="0"> New &nbsp;&nbsp</c:when>
		</c:choose>	
		
		<c:choose>
			<c:when test="${product.ICON_HIT!=null}"><input type="checkbox" name="ICON_HIT" value="1" checked> Hit &nbsp;&nbsp</c:when>
			<c:when test="${product.ICON_HIT==null}"><input type="checkbox" name="ICON_HIT" value="0"> Hit &nbsp;&nbsp</c:when>
		</c:choose>	
		
		<c:choose>
			<c:when test="${product.ICON_SALE!=null}">
				<input type="checkbox" name="ICON_SALE" value="1" onclick="form1.discount.disabled=!form1.discount.disabled;" checked> Sale &nbsp;&nbsp
				할인율 : <input type="text" name="DISCOUNT" value="${Product.DISCOUNT}" size="3" maxlength="3">
			</c:when>
			
			<c:when test="${product.ICON_SALE==null}">
			<input type="checkbox" name="ICON_SALE" value="0" onclick="form1.discount.disabled=!form1.discount.disabled;"> Sale &nbsp;&nbsp
			할인율 : <input type="text" name="DISCOUNT" value="${Product.DISCOUNT}" size="3" maxlength="3" disabled>
			</c:when>
		</c:choose>	
			
		</td>
	</tr>

	<tr> 
		<td width="100" bgcolor="#CCCCCC" align="center">이미지</td>
		<td width="700"  bgcolor="#F2F2F2">

			<table border="0" cellspacing="0" cellpadding="0" align="left">		
				<tr>
					<td>
						<table width="390" border="0" cellspacing="0" cellpadding="0">
						<c:forEach items="${image}" var="image">
							<tr>
								<td>
									<input type='hidden' name='imagename1'>
									<b>이미지</b>:<input type="text" name="text3" value="${image}" disabled>  <BR>
									수정>><input type="file" name="file" />
									<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
								</td>
							</tr> 
						</c:forEach>
						</table>
<%-- 							<tr>
								<td>
									<input type='hidden' name='imagename2' value='${product.image2}'>
									&nbsp;<input type="checkbox" name="checkno2" value="1"> <b>이미지2</b>: 
									<input type="text" name="text3" value="${product.image2}" disabled>수정>><input type="file" name="fileUpload2" size="20" value="찾아보기" onclick="fileReset(text2, fileUpload2)">
									<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
								</td>
							</tr> 
							<tr>
								<td>
									<input type='hidden' name='imagename3' value='${product.image3}'>
									&nbsp;<input type="checkbox" name="checkno3" value="1"> <b>이미지3</b>:
										<input type="text" name="text3" value="${product.image3}" disabled>수정>><input type="file" name="fileUpload3" size="20" value="찾아보기" onclick="fileReset(text3, fileUpload3)">
									<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
								</td>
							</tr> 
				  	</table> --%>
						<br><br><br><br><br>
						<table width="390" border="0" cellspacing="0" cellpadding="0">
							<tr>
								
								<td  valign="middle">&nbsp;
								<c:forEach items="${image}" var="image">
									<img src="/resources/image/${image}" width="50" height="50" border="1" style='cursor:hand' onclick="imageView('/resources/image/${image}')">&nbsp;
								</c:forEach>
								</td>
							</tr>				 
						</table>
					</td>
					<td>
						<td align="right" width="310"><img name="big" width="300" height="300" border="1"></td>
					</td>
				</tr>
				
			</table>

		</td>
	</tr>
</c:forEach>
</table>

<br>
<table width="800" border="0" cellspacing="0" cellpadding="5">
	<tr> 
		<td align="center">
			<input type="submit" value="수정하기"> &nbsp;&nbsp
			<input type="button" value="이전화면" onClick="javascript:history.back();">
		</td>
	</tr>
</table>

</form>
</body>
</html>